import { Button, Result } from 'antd';
import { history, Link } from '@umijs/max';
import { useEffect } from 'react';

export default function UnAccessible() {

  useEffect(() => {
    if (window.location.pathname === '/') {
      const loginUrl = localStorage.getItem('GeminisLoginUrl');
      if (loginUrl) {
        history.push(loginUrl);
      }
    }
  }, []);

  return (
    <Result
      status="403"
      title="403"
      subTitle="抱歉，你无权访问该页面"
      extra={<Link to={localStorage.getItem('GeminisLoginUrl') + '?return=' + encodeURI(window.location.href)}><Button
        type="primary">重新登录</Button></Link>}
    />
  );
}
